import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.crypto.Data;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

class User{

    public String username;
    public String password;

}
@WebServlet("/json")
public class JsonServlet extends HelloServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //实现servlet每隔一秒刷新一次页面
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html:charset=utf8");
        resp.setHeader("refresh","1");//1秒刷新一次
        Date d = new Date();//获取当前系统的时间

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
        String s = sdf.format(d);

        resp.getWriter().write(s);
    }
}
